package org.jianfa.learn.dubbo.consumer;

import org.jianfa.learn.dubbo.api.HelloService;
import org.jianfa.learn.dubbo.filter.TpMonitorReporter;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class DubboConsumerApplication {

    public static void main(String[] args) throws Exception{
        //TpMonitorReporter
        TpMonitorReporter tpMonitorReporter = new TpMonitorReporter();

        ClassPathXmlApplicationContext applicationContext  = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
        //applicationContext.start();
        HelloService  helloService  = applicationContext.getBean("helloService", HelloService.class);

        ExecutorService executorService = Executors.newFixedThreadPool(60);
        while(true) {
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    helloService.methodA();
                    helloService.methodB();
                    helloService.methodC();
                    //System.out.println("Server Response: "+ result);
                }
            });
            TimeUnit.SECONDS.sleep(1);
        }
    }
}
